Skip to content

Add format number with thousands separator and no decimal #4444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

reetp
Copy link

@reetp reetp commented Apr 14, 2025

Add format number with thousands separator and no decimal "#,##0'"

This is:

  • [X ] a new feature

Why this change is needed?

Because I can't format a number wihtout decimal places.

Fixes Github #4443

Add format number with thousands separator and no decimal "#,##0'"
@@ -16,6 +16,7 @@ class NumberFormat extends Supervisor
const FORMAT_NUMBER_00 = '0.00';
const FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00';
const FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-';
const FORMAT_NUMBER_COMMA_SEPARATED3 = '#,##0';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a more descriptive name for the constant, e.g. FORMAT_NUMBER_COMMA_SEPARATED_INTEGER.

@oleibman
Copy link
Collaborator

Please add formal unit test(s) to show that your new constant works correctly.

@oleibman
Copy link
Collaborator

3 months, no update, closing.

@oleibman oleibman closed this Jul 15, 2025
@reetp
Copy link
Author

reetp commented Jul 15, 2025

I'm not a coder so no idee how to do tests.

Thanks.

@oleibman
Copy link
Collaborator

Wouldn't it be better if you told me that when I asked instead of just ignoring my request?

Feel free to open a new PR if you wish. Your test should actually be pretty easy. Take a look at tests/data/NumberFormat.php. It has entries like:

    [
        ' $ 1,111.11 ',
        '1111.111',
        NumberFormat::FORMAT_ACCOUNTING_USD,
    ],

The second line is the expected result of the formatting, the next line is the value which is to be formatted, and the next line is the format which is to be used. Add an entry to this file using your new constant. Be aware of my comment above that a more descriptive name is needed for the constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants